package com.example.administrator.baikangxing.Dao;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;


import com.example.administrator.baikangxing.config.Constants;

import static android.content.Context.MODE_WORLD_READABLE;


public class OperateData {

    public static void saveStringData(Context context,String name, String data) {
        SharedPreferences preferences = context.getSharedPreferences(name,MODE_WORLD_READABLE);
        SharedPreferences.Editor edit = preferences.edit();
        edit.putString(name, data);
        edit.commit();
    }

    public static void saveBooleanData(Context context,String key, boolean b) {
        SharedPreferences preferences = context.getSharedPreferences(key, MODE_WORLD_READABLE);
        SharedPreferences.Editor edit = preferences.edit();
        edit.putBoolean(key,b);
        edit.commit();
    }

    public static void saveIntData(Context context,String name,int data){
        SharedPreferences preferences = context.getSharedPreferences(name, MODE_WORLD_READABLE);
        SharedPreferences.Editor edit = preferences.edit();
        edit.putInt(name,data);
        edit.commit();
    }

    public static String getStringData(Context context,String name ) {
        SharedPreferences preferences = context.getSharedPreferences(name, MODE_WORLD_READABLE);
        String string = preferences.getString(name, "0");
        return string;
    }
    public static int getIntData(Context context,String name ){
        SharedPreferences preferences =context.getSharedPreferences(name, MODE_WORLD_READABLE);
        int number= preferences.getInt(name,0);
        return number;
    }
    public static boolean getBooleanData(Context context,String key ){
        SharedPreferences preferences = context.getSharedPreferences(key, MODE_WORLD_READABLE);
        boolean b = preferences.getBoolean(key,false);
        return b;
    }


}
